package com.platform.usercenter.service.impl;

import java.util.List;

import com.platform.common.core.utils.DateUtils;
import com.platform.common.security.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import com.platform.usercenter.mapper.SysAppPermissionMapper;
import com.platform.usercenter.domain.SysAppPermission;
import com.platform.usercenter.service.ISysAppPermissionService;

import javax.annotation.Resource;

/**
 * 应用数据权限关系Service业务层处理
 *
 * @author platform
 * @date 2024-10-28
 */
@Service
public class SysAppPermissionServiceImpl implements ISysAppPermissionService
{
    @Resource
    private SysAppPermissionMapper sysAppPermissionMapper;

    /**
     * 查询应用数据权限关系
     *
     * @param permissionId 应用数据权限关系主键
     * @return 应用数据权限关系
     */
    @Override
    public SysAppPermission selectSysAppPermissionByPermissionId(Long permissionId)
    {
        return sysAppPermissionMapper.selectSysAppPermissionByPermissionId(permissionId);
    }

    /**
     * 查询应用数据权限关系列表
     *
     * @param sysAppPermission 应用数据权限关系
     * @return 应用数据权限关系
     */
    @Override
    public List<SysAppPermission> selectSysAppPermissionList(SysAppPermission sysAppPermission)
    {
        return sysAppPermissionMapper.selectSysAppPermissionList(sysAppPermission);
    }

    /**
     * 新增应用数据权限关系
     *
     * @param sysAppPermission 应用数据权限关系
     * @return 结果
     */
    @Override
    public int insertSysAppPermission(SysAppPermission sysAppPermission)
    {
        sysAppPermission.setCreateTime(DateUtils.getNowDate());
        return sysAppPermissionMapper.insertSysAppPermission(sysAppPermission);
    }

    /**
     * 修改应用数据权限关系
     *
     * @param sysAppPermission 应用数据权限关系
     * @return 结果
     */
    @Override
    public int updateSysAppPermission(SysAppPermission sysAppPermission)
    {
        sysAppPermission.setUpdateBy(SecurityUtils.getUsername());
        sysAppPermission.setUpdateTime(DateUtils.getNowDate());
        return sysAppPermissionMapper.updateSysAppPermission(sysAppPermission);
    }

    /**
     * 批量删除应用数据权限关系
     *
     * @param permissionIds 需要删除的应用数据权限关系主键
     * @return 结果
     */
    @Override
    public int deleteSysAppPermissionByPermissionIds(Long[] permissionIds)
    {
        return sysAppPermissionMapper.deleteSysAppPermissionByPermissionIds(permissionIds);
    }

    /**
     * 删除应用数据权限关系信息
     *
     * @param permissionId 应用数据权限关系主键
     * @return 结果
     */
    @Override
    public int deleteSysAppPermissionByPermissionId(Long permissionId)
    {
        return sysAppPermissionMapper.deleteSysAppPermissionByPermissionId(permissionId);
    }
}
